/**
 * Project Name:EMSInterfaceTest
 * File Name:PayAmountCalculationOfBatch.java
 * Package Name:functions.ems_payment
 * Date:2018年7月27日上午9:59:59
 * Copyright (c) 2018, crpcg@crpcg.com All Rights Reserved.
 *
 */

package functions.ems_payment;
/**
 * ClassName:PayAmountCalculationOfBatch <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason:	 TODO ADD REASON. <br/>
 * Date:     2018年7月27日 上午9:59:59 <br/>
 * @author   JiangWu	 
 */

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.beans.PayAmountCalculationBean;
import coms.Constants;
import frame.HttpHelper;
import frame.InterTest;

public class PayAmountCalculationOfBatch implements InterTest{
	private static Logger logger = LoggerFactory.getLogger(PayAmountCalculationOfBatch.class);
	String result;
	String payBatchId = "2";
	List<PayAmountCalculationBean> pAmountCalculationBeans;
	
	public PayAmountCalculationOfBatch() {
	}
	
	/*
	 * public static String selectAmountOfBatchUrl="/payAmountCalculationOfBatch/selectAmountOfBatch"
	 */
	public void selectAmountOfBatch() {
		String url = Constants.SELECT_AMOUNT_OF_BATCH_URL + '/'+payBatchId;
		try {
			result = HttpHelper.post("", url);
			logger.info("selectAmountOfBatch==============="+result);
			JSONObject jsonObject = new JSONObject(result);
			pAmountCalculationBeans = new ArrayList<PayAmountCalculationBean>();
			String applyPayAmount = jsonObject.getString("applyPayAmount");
			String unpreparedAmount = jsonObject.getString("unpreparedAmount");
			String preparedAmount = jsonObject.getString("preparedAmount");
			String rejectAmount = jsonObject.getString("rejectAmount");
			String realPayAmount = jsonObject.getString("realPayAmount");
			PayAmountCalculationBean payAmountCalculationBean = new PayAmountCalculationBean(applyPayAmount, unpreparedAmount, preparedAmount, rejectAmount, realPayAmount);
			pAmountCalculationBeans.add(payAmountCalculationBean);
		} catch (Exception e) {
			
			// TODO Auto-generated catch block
			e.printStackTrace();
			
		}
	}
	
	/*
	 * updateAmountOfBatchUrl="http://10.0.49.62:7023/payAmountCalculationOfBatch/updateAmountOfBatch
	 */
	public void updateAmountOfBatch() {
		String url = Constants.UPDATE_AMOUNT_OF_BATCH_URL + "/"+payBatchId;
		try {
			result = HttpHelper.post("", url);
			logger.info("updateAmountOfBatch================="+result);
		} catch (Exception e) {
			
			// TODO Auto-generated catch block
			e.printStackTrace();
			
		}
	}



	/**
	 * TODO 简单描述该方法的实现功能（可选）.
	 * @see frame.InterTest#run(java.util.HashMap)
	 */
	@Override
	public void run(Map<Object, Object> paramMap) {
		
		// TODO Auto-generated method stub
	  selectAmountOfBatch();
      updateAmountOfBatch();
	}

  @Override
  public boolean getStatus() {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public String getRemark() {
    // TODO Auto-generated method stub
    return null;
  }
}

